import SDKAdatper from "../core/SDKAdatper";
import { SelfAdAdapter } from "../core/SelfAdAdapter";
class F399RewardAd extends SelfAdAdapter {


    protected remain: number
    protected canPlayAd: boolean;
    protected sdk: any;
    constructor(sdk: any, data: any) {
        super(null, data)
        this.sdk = sdk;
        this.sdk.canPlayAd((data: any) => {
            this.remain = data.remain;
            this.canPlayAd = data.canPlayAd;
            console.log("loadConfig 是否可播放广告", this.canPlayAd, "剩余次数", this.remain)
        })
    }


    show() {
        this.sdk.playAd((obj: any) => {
            console.log('代码:' + obj.code + ',消息:' + obj.message)
            if (obj.code === 10000) {
                console.log('开始播放')
            } else if (obj.code === 10001) {
                console.log('播放结束')
                this.closeListener.emit({ isEnded: true })
            } else {
                console.log('广告异常')
                this.errorListener.emit({ msg: obj.message })
            }
        })
    }

    load() {

    }
}
export default class F399SDK extends SDKAdatper {
    createRewardedVideoAd(obj: any) {
        if (!this.hasSDK()) {
            return null;
        }

        return new F399RewardAd(this._sdk, obj)

    }
}